#Programme en POO qui comprend des méthodes qui permettent de calculer la moyenne d'un élèves parmi ceux d'un tableau class ElevesNotes: def __init__(self, eleve, notes): self.notes = notes self.eleve = eleve def enfile(self, note, indice_eleve): return self.notes[indice_eleve].append(note) def defile(self, indice_note, indice_eleve): return self.notes[indice_eleve].pop(indice_note) def ajout_eleve(self, nom_eleve, noms_eleves, ses_notes): return noms_eleves.append(nom_eleve) return self.notes.append(ses_notes) def moyenne(self): total = 0 for i in self.notes[self.eleve]: total += i moyenne = total/len(self.notes[self.eleve]) return moyenne eleves = ["a","b","c","d"] notes = [[12,13,15,19],[11,17,14,9],[13,15,18,18],[10,20,20,20]] for i in range(len(eleves)): eleves_notes = ElevesNotes(i,notes) print("la moyenne de l'élève",i,"est",eleves_notes.moyenne()) print("Nouvelle note!") eleves_notes.enfile(17, 0) eleves_notes.enfile(7, 1) eleves_notes.enfile(1, 2) eleves_notes.enfile(12, 3) for i in range(len(eleves)): eleves_notes = ElevesNotes(i,notes) print("la moyenne de l'élève",eleves[i],"est",eleves_notes.moyenne()) print("Suppression d'une note!") eleves_notes.defile(0, 0) eleves_notes.defile(0, 1) eleves_notes.defile(0, 2) eleves_notes.defile(0, 3) for i in range(len(eleves)): eleves_notes = ElevesNotes(i,notes) print("la moyenne de l'élève",eleves[i],"est",eleves_notes.moyenne()) print("Ajout d'un élève!'") eleves_notes.ajout_eleve("e", eleves, [20,20,18,19]) for i in range(len(eleves)): eleves_notes = ElevesNotes(i,notes) print("la moyenne de l'élève",eleves[i],"est",eleves_notes.moyenne())